﻿using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FubiManger.Controls;
using DAL;
using Model;

namespace FubiManger.UI
{
    partial class UserinfoForm : Smobiler.Core.Controls.MobileForm
    {
        public UserinfoForm() : base()
        {
            //This call is required by the SmobilerForm.
            InitializeComponent();
        }
        /// <summary>
        /// 用户ID
        /// </summary>
        public string uid { get; set; }
        /// <summary>
        /// 商户ID
        /// </summary>
        public string merchantid { get; set; }
        private void panclose_Press(object sender, EventArgs e)
        {
            this.Close();
        }

        private void UserinfoForm_Load(object sender, EventArgs e)
        {
            ms_user user = new ms_user();
            if (merchantid == "2")
                user = userDal.Loginbyuid1(uid);
            else
                user = userDal.Loginbyuid(uid);
            List<ms_merchant_level> levellist = merchant_levelDal.Querybymerid(merchantid);
            imgcover.ResourceID = @"C:\fbheard\" + user.head_portrait;//头像
            lblusername.Text = user.nickname;//用户名
            lbluserdate.Text = Convert.ToDateTime(user.register_time).ToString("yyyy-MM-dd");
            lblintegral.Text = user.integral.ToString();//积分
            lblmoney.Text = userDal.Querymoney(uid, merchantid).ToString();//消费金额
            lblcount.Text = userDal.Querycount(uid, merchantid).ToString();//消费次数
            for (int i = 0; i < levellist.Count; i++)
            {
                levelcontrol con = new levelcontrol();
                con.level = levellist[i].lv_num;
                con.money = Convert.ToInt32(lblmoney.Text);
                con.amount = levellist[i].amount;//等级所需金额
                panlevel.Controls.Add(con);
            }
        }
    }
}